package com.luozy.common.clients;

import com.luozy.common.dto.Item;
import com.luozy.common.dto.PageDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient("itemservice")
public interface ItemClient {

    //远程调用分页查询商品接口
    @GetMapping("/item/list")
    PageDTO<Item> findPage(@RequestParam Integer page, @RequestParam Integer size);

    //远程调用根据id查询商品接口
    @GetMapping("item/{id}")
    Item getById(@PathVariable Long id);

    //扣减库存
    @PutMapping("item/stock/{itemId}/{num}")
    void deductStock(@PathVariable Long itemId, @PathVariable Integer num);
}
